#ifndef FRHOADON_CTHD_H
#define FRHOADON_CTHD_H

#include <QDialog>
#include "ui_frhoadon_cthd.h"
#include "ketnoidb.h"
#include "qsqlquery.h"
#include "qsqlquerymodel.h"

namespace Ui {
    class frHoaDon_CTHD;
}

class frHoaDon_CTHD : public QDialog
{
    Q_OBJECT

public:
    explicit frHoaDon_CTHD(QWidget *parent = 0);
    ~frHoaDon_CTHD();
    //QSqlDatabase *db;
    ketnoiDB thaotac;
    QSqlQuery query;
    //
    //QItemSelectionModel *selectionModel;
    int maPX;
    QSqlQueryModel *qModel;
    QString lenh;




private slots:
    void select(QItemSelection);
    void selectCT(QItemSelection);

    void suathemPX(QString sss);
    void  suathemCTPX(QString sss);

    void khoaDKPX(bool d);

    void khoaDKCTP(bool d);

    void loadcbo();

    void loadPX();

    void loadCTPX();//ok co ham roi de em ma cai cbo chon load o tab len cbo load sao

    void on_cboMaDL_PX_currentIndexChanged(const QString &arg1);

    void on_pushButton_clicked();

    void on_btnThemPX_clicked();

    void on_btnSuaPX_clicked();

    void on_btnKLPX_clicked();

    void on_btnLuu_PX_clicked();

    void on_btnThemCTP_clicked();

    void on_btnKhogLCTP_clicked();

    void on_btnLuuCTP_clicked();

    void on_btnSuaCTP_clicked();

    void on_btnXoaCTP_clicked();

    void on_btnXoaPX_clicked();

    void on_cboMatHang_currentIndexChanged(const QString &arg1);
    void xoatext();

private:
    Ui::frHoaDon_CTHD *ui;
    QString laythongtinMatHang(QString mahang);
    QString laythongtinDaiLy(QString madl);
    QString kiemtra(QString makt);
    float laythanhtien(QString tt);
    int laySoLuong(QString sl);
};

#endif // FRHOADON_CTHD_H
